//
//  ZCModelUser.m
//  zctx
//
//  Created by Darren Zheng on 15/10/8.
//  Copyright © 2015年 sanliang. All rights reserved.
//

#import "ZCUserModel.h"

@implementation ZCUserModel

+ (ZCUserModel *)sharedInstance
{
    static ZCUserModel *sharedInstance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sharedInstance = [[self alloc] init];
    });
    return sharedInstance;
}

- (void)setMobile:(NSString *)mobile
{
    [[NSUserDefaults standardUserDefaults] setObject:mobile forKey:@"mobile"];
    [[NSUserDefaults standardUserDefaults]synchronize];
}

- (NSString *)mobile
{
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"mobile"];
}



-(void)setSearchArray:(NSMutableArray *)searchArray{
    [[NSUserDefaults standardUserDefaults] setObject:searchArray forKey:@"search"];
    [[NSUserDefaults standardUserDefaults]synchronize];
}

-(NSMutableArray *)searchArray{
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"search"];
}



- (void)setUsername:(NSString *)username
{
    [[NSUserDefaults standardUserDefaults] setObject:username forKey:@"username"];
    [[NSUserDefaults standardUserDefaults]synchronize];
}

- (NSString *)username
{
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"username"];
}
- (void)setPassword:(NSString *)password
{
    [[NSUserDefaults standardUserDefaults] setObject:password forKey:@"password"];
    [[NSUserDefaults standardUserDefaults]synchronize];
}

- (NSString *)password
{
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"password"];
}

-(void)setUseCount:(NSString *)useCount{
    [[NSUserDefaults standardUserDefaults] setObject:useCount forKey:@"usecount"];
    [[NSUserDefaults standardUserDefaults]synchronize];
}

-(NSString *)useCount{
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"usecount"];
}

-(void)setMainCount:(NSString *)mainCount{
    [[NSUserDefaults standardUserDefaults] setObject:mainCount forKey:@"maincount"];
    [[NSUserDefaults standardUserDefaults]synchronize];
}

-(NSString *)mainCount{
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"maincount"];
}

- (void)setMid:(NSString *)mid
{
    [[NSUserDefaults standardUserDefaults] setObject:mid forKey:@"mid"];
    [[NSUserDefaults standardUserDefaults]synchronize];
}

- (NSString *)mid
{
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"mid"];
}

-(void)setAvatar:(NSString *)avatar{
    [[NSUserDefaults standardUserDefaults] setObject:avatar forKey:@"avatar"];
    [[NSUserDefaults standardUserDefaults]synchronize];
}

- (NSString *)avatar
{
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"avatar"];
}

-(void)setGender:(NSString *)gender{
    [[NSUserDefaults standardUserDefaults] setObject:gender forKey:@"gender"];
    [[NSUserDefaults standardUserDefaults]synchronize];
}

-(NSString *)gender{
     return [[NSUserDefaults standardUserDefaults] objectForKey:@"gender"];
}

-(void)setAddress:(NSString *)address{
    [[NSUserDefaults standardUserDefaults] setObject:address forKey:@"address"];
    [[NSUserDefaults standardUserDefaults]synchronize];
}
-(NSString *)address{
     return [[NSUserDefaults standardUserDefaults] objectForKey:@"address"];
}

-(void)setBirthday:(NSString *)birthday{
    [[NSUserDefaults standardUserDefaults] setObject:birthday forKey:@"birthday"];
    [[NSUserDefaults standardUserDefaults]synchronize];
}
-(NSString *)birthday{
     return [[NSUserDefaults standardUserDefaults] objectForKey:@"birthday"];
}
-(void)setUserIcon:(UIImage *)userIcon{
    
    NSData *data = UIImagePNGRepresentation(userIcon);
    [[NSUserDefaults standardUserDefaults] setObject:data forKey:@"userIcon"];
    [[NSUserDefaults standardUserDefaults]synchronize];
}

-(UIImage *)userIcon{
    NSData *data = [[NSUserDefaults standardUserDefaults] objectForKey:@"userIcon"];
    UIImage *image = [UIImage imageWithData: data];
    return image;
}




@end
